public class Work04 {
    private static int nums[] = {1,2,3,4,5}; //组合需要用到的数字
    private static int isUsed[] = new int[20]; //记录第i个数字有没有使用过

    public static void dfs(int start,int end){
        if(start == end){
            for (int i = 0; i < end; i++) {
                if(isUsed[i] == 1){
                    System.out.print(nums[i]);
                }
            }
            System.out.println();
        }else{
            isUsed[start] = 0;
            dfs(start+1,end);
            isUsed[start] = 1;
            dfs(start+1,end);
        }
    }

    public static void main(String[] args) {
        // 给出n个数，求组合

        dfs(0,4);
    }
}
